editeng/source/outliner/outlvw.cxx        |   12 +++++
 include/editeng/outliner.hxx              |    2 
 sw/inc/AnnotationWin.hxx                  |    5 --
 sw/inc/fmtfld.hxx                         |    3 -
 sw/source/core/fields/textapi.cxx         |    4 +
 sw/source/core/text/txtfld.cxx            |    5 --
 sw/source/uibase/docvw/AnnotationWin.cxx  |   18 -------
 sw/source/uibase/docvw/AnnotationWin2.cxx |   72 ------------------------------
 sw/source/uibase/docvw/PostItMgr.cxx      |   29 ------------
 9 files changed, 20 insertions(+), 130 deletions(-)

New commits:
commit 6cb6f76095d2df07102ffd3da7accf7d075df90b
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Thu Jun 15 11:39:25 2023 +0300
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Fri Jun 16 00:49:09 2023 +0200

    tdf#103064 sw: use the comment style by default instead of DF
    
    As part of that, language changes in the document's body are
    no longer applied to comments, as that would be a DF. Instead,
    the default language of comments is controlled via the style
    (see tdf#153805 for the use case).
    
    Change-Id: Icfa9a7334b52fe74292e82fa8daa01a15197e384
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153158
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index 705b5e10b06b..382d1d63f7da 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -715,6 +715,18 @@ void OutlinerView::CreateSelectionList 
(std::vector<Paragraph*> &aSelList)
     }
 }
 
+void OutlinerView::SetStyleSheet(const OUString& rStyleName)
+{
+    ParaRange aParas = ImpGetSelectedParagraphs(false);
+
+    auto pStyle = pOwner->GetStyleSheetPool()->Find(rStyleName, 
SfxStyleFamily::Para);
+    if (!pStyle)
+        return;
+
+    for (sal_Int32 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; 
nPara++)
+        pOwner->SetStyleSheet(nPara, static_cast<SfxStyleSheet*>(pStyle));
+}
+
 const SfxStyleSheet* OutlinerView::GetStyleSheet() const
 {
     return pEditView->GetStyleSheet();
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 7622138271ee..0b9b06395dba 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -267,6 +267,8 @@ public:
     void        Paste( bool bUseSpecial = false );
     void        PasteSpecial();
 
+    void SetStyleSheet(const OUString& rStyleName);
+
     const SfxStyleSheet*  GetStyleSheet() const;
     SfxStyleSheet*  GetStyleSheet();
 
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index c3d556085a03..f7ac7b301d46 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -171,8 +171,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
         bool IsMouseOverSidebarWin() const { return mbMouseOver; }
 
-        void SetLanguage(const SvxLanguageItem& rNewItem);
-
         void ChangeSidebarItem( SwSidebarItem const & rSidebarItem );
         virtual css::uno::Reference< css::accessibility::XAccessible > 
CreateAccessible() override;
 
@@ -216,7 +214,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
         virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
 
         void        SetSizePixel( const Size& rNewSize ) override;
-        SfxItemSet  DefaultItem();
 
         DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone*, void);
         DECL_DLLPRIVATE_LINK(ScrollHdl, weld::ScrolledWindow&, void);
@@ -228,8 +225,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
         sal_uInt32 CountFollowing();
 
-        SvxLanguageItem GetLanguage() const;
-
         void SetMenuButtonColors();
 
         SwPostItMgr&    mrMgr;
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 6f5811539b17..4c4c1ea91293 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -178,8 +178,7 @@ enum class SwFormatFieldHintWhich
     REMOVED    = 2,
     FOCUS      = 3,
     CHANGED    = 4,
-    LANGUAGE   = 5,
-    RESOLVED   = 6
+    RESOLVED   = 5
 };
 
 class SW_DLLPUBLIC SwFormatFieldHint final : public SfxHint
diff --git a/sw/source/core/fields/textapi.cxx 
b/sw/source/core/fields/textapi.cxx
index 88520065c7e3..6dcdc99d3b47 100644
--- a/sw/source/core/fields/textapi.cxx
+++ b/sw/source/core/fields/textapi.cxx
@@ -22,6 +22,7 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <docsh.hxx>
 #include <docstyle.hxx>
+#include <strings.hrc>
 #include <SwStyleNameMapper.hxx>
 #include <unoprnms.hxx>
 #include <editeng/eeitem.hxx>
@@ -189,6 +190,9 @@ void SwTextAPIEditSource::SetString( const OUString& rText )
         m_pImpl->mpOutliner->Clear();
 
     EnsureOutliner();
+
+    if (auto pStyle = 
m_pImpl->mpOutliner->GetStyleSheetPool()->Find(SwResId(STR_POOLCOLL_COMMENT), 
SfxStyleFamily::Para))
+        m_pImpl->mpOutliner->SetStyleSheet(0, 
static_cast<SfxStyleSheet*>(pStyle));
     m_pImpl->mpOutliner->Insert( rText );
 }
 
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 004a2bc17c09..aa8fef7331c5 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -88,12 +88,7 @@ SwExpandPortion *SwTextFormatter::NewFieldPortion( 
SwTextFormatInfo &rInf,
     // set language
     const_cast<SwTextFormatter*>(this)->SeekAndChg( rInf );
     if (pField->GetLanguage() != GetFnt()->GetLanguage())
-    {
         pField->SetLanguage( GetFnt()->GetLanguage() );
-        // let the visual note know about its new language
-        if (pField->GetTyp()->Which()==SwFieldIds::Postit)
-            const_cast<SwFormatField*> (&pHint->GetFormatField())->Broadcast( 
SwFormatFieldHint( &pHint->GetFormatField(), SwFormatFieldHintWhich::LANGUAGE ) 
);
-    }
 
     SwViewShell *pSh = rInf.GetVsh();
     SwDoc *const pDoc( pSh ? pSh->GetDoc() : nullptr );
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index 3d350048055b..4654e376e464 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -189,7 +189,7 @@ void SwAnnotationWin::SetPostItText()
     else
     {
         mpOutliner->Clear();
-        GetOutlinerView()->SetAttribs(DefaultItem());
+        GetOutlinerView()->SetStyleSheet(SwResId(STR_POOLCOLL_COMMENT));
         GetOutlinerView()->InsertText(sNewText);
     }
 
@@ -456,7 +456,6 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject const & 
rText)
 
     //remove all attributes and reset our standard ones
     GetOutlinerView()->GetEditView().RemoveAttribsKeepLanguages(true);
-    GetOutlinerView()->SetAttribs(DefaultItem());
     // lets insert an undo step so the initial text can be easily deleted
     // but do not use UpdateData() directly, would set modified state again 
and reentrance into Mgr
     mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() );
@@ -488,21 +487,6 @@ void SwAnnotationWin::UpdateText(const OUString& aText)
     UpdateData();
 }
 
-SvxLanguageItem SwAnnotationWin::GetLanguage() const
-{
-    // set initial language for outliner
-    SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( 
mpField->GetLanguage() );
-    sal_uInt16 nLangWhichId = 0;
-    switch (nScriptType)
-    {
-        case SvtScriptType::LATIN :    nLangWhichId = EE_CHAR_LANGUAGE ; break;
-        case SvtScriptType::ASIAN :    nLangWhichId = EE_CHAR_LANGUAGE_CJK; 
break;
-        case SvtScriptType::COMPLEX :  nLangWhichId = EE_CHAR_LANGUAGE_CTL; 
break;
-        default: OSL_FAIL("GetLanguage: wrong script type");
-    }
-    return SvxLanguageItem(mpField->GetLanguage(),nLangWhichId);
-}
-
 bool SwAnnotationWin::IsReadOnlyOrProtected() const
 {
     return mbReadonly ||
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index d531a62e1f57..86348469f853 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -280,13 +280,6 @@ void SwAnnotationWin::ShowAnchorOnly(const Point &aPoint)
         mpShadow->setVisible(false);
 }
 
-SfxItemSet SwAnnotationWin::DefaultItem()
-{
-    SfxItemSet aItem( mrView.GetDocShell()->GetPool() );
-    aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
-    return aItem;
-}
-
 void SwAnnotationWin::InitControls()
 {
     // window controls for author and date
@@ -345,8 +338,6 @@ void SwAnnotationWin::InitControls()
     mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
     mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) );
 
-    mpOutlinerView->SetAttribs(DefaultItem());
-
     mxVScrollbar->set_direction(false);
     mxVScrollbar->connect_vadjustment_changed(LINK(this, SwAnnotationWin, 
ScrollHdl));
     mxVScrollbar->connect_mouse_move(LINK(this, SwAnnotationWin, 
MouseMoveHdl));
@@ -395,7 +386,6 @@ void SwAnnotationWin::InitControls()
     mxMenuButton->connect_key_press(LINK(this, SwAnnotationWin, KeyInputHdl));
     mxMenuButton->connect_mouse_move(LINK(this, SwAnnotationWin, 
MouseMoveHdl));
 
-    SetLanguage(GetLanguage());
     GetOutlinerView()->StartSpeller(mxSidebarTextControl->GetDrawingArea());
     SetPostItText();
     mpOutliner->CompleteOnlineSpelling();
@@ -911,67 +901,6 @@ void SwAnnotationWin::SetReadonly(bool bSet)
     GetOutlinerView()->SetReadOnly(bSet);
 }
 
-void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem)
-{
-    IDocumentUndoRedo& rUndoRedo(
-        mrView.GetDocShell()->GetDoc()->GetIDocumentUndoRedo());
-    const bool bDocUndoEnabled = rUndoRedo.DoesUndo();
-    const bool bOutlinerUndoEnabled = mpOutliner->IsUndoEnabled();
-    const bool bOutlinerModified = mpOutliner->IsModified();
-    const bool bDisableAndRestoreUndoMode = !bDocUndoEnabled && 
bOutlinerUndoEnabled;
-
-    if (bDisableAndRestoreUndoMode)
-    {
-        // doc undo is disabled, but outliner was enabled, turn outliner undo 
off
-        // for the duration of this function
-        mpOutliner->EnableUndo(false);
-    }
-
-    Link<LinkParamNone*,void> aLink = mpOutliner->GetModifyHdl();
-    mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() );
-    ESelection aOld = GetOutlinerView()->GetSelection();
-
-    ESelection aNewSelection( 0, 0, mpOutliner->GetParagraphCount()-1, 
EE_TEXTPOS_ALL );
-    GetOutlinerView()->SetSelection( aNewSelection );
-    SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs());
-    aEditAttr.Put(rNewItem);
-    GetOutlinerView()->SetAttribs( aEditAttr );
-
-    if (!mpOutliner->IsUndoEnabled() && !bOutlinerModified)
-    {
-        // if undo was disabled (e.g. this is a redo action) and we were
-        // originally 'unmodified' keep it that way
-        mpOutliner->ClearModifyFlag();
-    }
-
-    GetOutlinerView()->SetSelection(aOld);
-    mpOutliner->SetModifyHdl( aLink );
-
-    EEControlBits nCntrl = mpOutliner->GetControlWord();
-    // turn off
-    nCntrl &= ~EEControlBits::ONLINESPELLING;
-    mpOutliner->SetControlWord(nCntrl);
-
-    if (SwWrtShell* pWrtShell = mrView.GetWrtShellPtr())
-    {
-        const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
-        //turn back on
-        if (pVOpt->IsOnlineSpell())
-            nCntrl |= EEControlBits::ONLINESPELLING;
-        else
-            nCntrl &= ~EEControlBits::ONLINESPELLING;
-    }
-    mpOutliner->SetControlWord(nCntrl);
-
-    mpOutliner->CompleteOnlineSpelling();
-
-    // restore original mode
-    if (bDisableAndRestoreUndoMode)
-        mpOutliner->EnableUndo(true);
-
-    Invalidate();
-}
-
 void SwAnnotationWin::GetFocus()
 {
     if (mxSidebarTextControl)
@@ -1251,7 +1180,6 @@ void SwAnnotationWin::ResetAttributes()
 {
     mpOutlinerView->RemoveAttribsKeepLanguages(true);
     mpOutliner->RemoveFields();
-    mpOutlinerView->SetAttribs(DefaultItem());
 }
 
 int SwAnnotationWin::GetPrefScrollbarWidth() const
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index bd92adadbf03..91dfcd2f2774 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -442,35 +442,6 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
                 }
                 break;
             }
-
-            case SwFormatFieldHintWhich::LANGUAGE:
-            {
-                SwFormatField* pFormatField = 
dynamic_cast<SwFormatField*>(&rBC);
-                for (auto const& postItField : mvPostItFields)
-                {
-                    if ( pFormatField == postItField->GetBroadcaster() )
-                    {
-                        if (postItField->mpPostIt)
-                        {
-                            const SvtScriptType nScriptType = 
SvtLanguageOptions::GetScriptTypeOfLanguage( 
postItField->GetFormatField().GetField()->GetLanguage() );
-                            sal_uInt16 nLangWhichId = 0;
-                            switch (nScriptType)
-                            {
-                            case SvtScriptType::LATIN :    nLangWhichId = 
EE_CHAR_LANGUAGE ; break;
-                            case SvtScriptType::ASIAN :    nLangWhichId = 
EE_CHAR_LANGUAGE_CJK; break;
-                            case SvtScriptType::COMPLEX :  nLangWhichId = 
EE_CHAR_LANGUAGE_CTL; break;
-                            default: break;
-                            }
-                            postItField->mpPostIt->SetLanguage(
-                                SvxLanguageItem(
-                                
postItField->GetFormatField().GetField()->GetLanguage(),
-                                nLangWhichId) );
-                        }
-                        break;
-                    }
-                }
-                break;
-            }
         }
     }
     else if ( const SfxStyleSheetModifiedHint * pStyleHint = 
dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint) )

Reply via email to