diff options
Diffstat (limited to 'sw/source/uibase/app/docst.cxx')
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 247 |
1 files changed, 189 insertions, 58 deletions
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index dd5609af368c..2b2c1b340403 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_wasm_strip.h> + #include <memory> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -26,6 +28,7 @@ #include <comphelper/flagguard.hxx> #include <o3tl/any.hxx> #include <sal/log.hxx> +#include <osl/diagnose.h> #include <hintids.hxx> #include <sfx2/styledlg.hxx> #include <svl/whiter.hxx> @@ -36,17 +39,17 @@ #include <sfx2/printer.hxx> #include <sfx2/viewfrm.hxx> #include <svl/stritem.hxx> -#include <svl/languageoptions.hxx> +#include <svl/ctloptions.hxx> #include <sfx2/htmlmode.hxx> #include <swmodule.hxx> #include <fchrfmt.hxx> -#include <svtools/htmlcfg.hxx> #include <svx/xdef.hxx> #include <SwStyleNameMapper.hxx> #include <SwRewriter.hxx> #include <numrule.hxx> #include <swundo.hxx> #include <svx/drawitem.hxx> +#include <utility> #include <view.hxx> #include <wrtsh.hxx> #include <docsh.hxx> @@ -71,12 +74,17 @@ #include <edtwin.hxx> #include <unochart.hxx> #include <swabstdlg.hxx> -#include <paratr.hxx> #include <tblafmt.hxx> #include <sfx2/watermarkitem.hxx> +#include <svl/grabbagitem.hxx> +#include <PostItMgr.hxx> +#include <AnnotationWin.hxx> #include <SwUndoFmt.hxx> #include <strings.hrc> #include <AccessibilityCheck.hxx> +#include <docmodel/theme/Theme.hxx> +#include <svx/svdpage.hxx> +#include <officecfg/Office/Common.hxx> using namespace ::com::sun::star; @@ -98,10 +106,9 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) } else { - SfxViewFrame* pFrame = pShell->GetView().GetViewFrame(); - std::unique_ptr<SfxPoolItem> pItem; - pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); + SfxViewFrame& rFrame = pShell->GetView().GetViewFrame(); + std::unique_ptr<SfxUInt16Item> pFamilyItem; + rFrame.GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem); if (pFamilyItem) { nActualFamily = static_cast<SfxStyleFamily>(pFamilyItem->GetValue()); @@ -124,6 +131,12 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) if( pFormat ) aName = pFormat->GetName(); } + else if (pShell->GetSelectionType() == SelectionType::PostIt) + { + auto pStyle = pShell->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->GetStyleSheet(); + if (pStyle) + aName = pStyle->GetName(); + } else { SwTextFormatColl* pColl = pShell->GetCurTextFormatColl(); @@ -148,11 +161,23 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) case SID_STYLE_FAMILY2: if(!pShell->IsFrameSelected()) { - SwTextFormatColl* pColl = pShell->GetCurTextFormatColl(); - if(pColl) + OUString aProgName; + if (pShell->GetSelectionType() == SelectionType::PostIt) + { + if (auto pStyle = pShell->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->GetStyleSheet()) + { + aName = pStyle->GetName(); + aProgName = SwStyleNameMapper::GetProgName(aName, SwGetPoolIdFromName::TxtColl); + } + } + else if (auto pColl = pShell->GetCurTextFormatColl()) + { aName = pColl->GetName(); + sal_uInt16 nId = pColl->GetPoolFormatId(); + SwStyleNameMapper::FillProgName(nId, aProgName); + } - SfxTemplateItem aItem(nWhich, aName); + SfxTemplateItem aItem(nWhich, aName, aProgName); SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto; if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE)) @@ -196,8 +221,7 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) case SID_STYLE_FAMILY4: { - SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get(); - if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !rHtmlOpt.IsPrintLayoutExtension()) + if (m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !officecfg::Office::Common::Filter::HTML::Export::PrintLayout::get()) rSet.DisableItem( nWhich ); else { @@ -312,14 +336,14 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) if (sName.isEmpty() && m_xBasePool) sName = SfxStyleDialogController::GenerateUnusedName(*m_xBasePool, nFamily); - Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq, nSlot); + Edit(rReq.GetFrameWeld(), sName, sParent, nFamily, nMask, true, {}, nullptr, &rReq, nSlot); } break; case SID_STYLE_APPLY: if( !pArgs ) { - GetView()->GetViewFrame()->GetDispatcher()->Execute(SID_STYLE_DESIGNER); + GetView()->GetViewFrame().GetDispatcher()->Execute(SID_STYLE_DESIGNER); break; } else @@ -351,6 +375,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) [[fallthrough]]; case SID_STYLE_EDIT: + case SID_STYLE_FONT: case SID_STYLE_DELETE: case SID_STYLE_HIDE: case SID_STYLE_SHOW: @@ -383,12 +408,17 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) case SID_STYLE_UPDATE_BY_EXAMPLE: case SID_STYLE_EDIT: { - SwTextFormatColl* pColl = GetWrtShell()->GetCurTextFormatColl(); - if(pColl) + if (GetWrtShell()->GetSelectionType() == SelectionType::PostIt) { + auto pOLV = GetWrtShell()->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView(); + if (auto pStyle = pOLV->GetStyleSheet()) + aParam = pStyle->GetName(); + } + else if (auto pColl = GetWrtShell()->GetCurTextFormatColl()) aParam = pColl->GetName(); + + if (!aParam.isEmpty()) rReq.AppendItem(SfxStringItem(nSlot, aParam)); - } } break; } @@ -430,9 +460,8 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) if( SfxItemState::SET == pArgs->GetItemState(SID_STYLE_MASK, false, &pItem )) nMask = static_cast<SfxStyleSearchBits>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); - if( SfxItemState::SET == pArgs->GetItemState(FN_PARAM_WRTSHELL, - false, &pItem )) - pActShell = pShell = static_cast<SwWrtShell*>(static_cast<const SwPtrItem*>(pItem)->GetValue()); + if( const SwPtrItem* pShellItem = pArgs->GetItemIfSet(FN_PARAM_WRTSHELL, false )) + pActShell = pShell = static_cast<SwWrtShell*>(pShellItem->GetValue()); if( nSlot == SID_STYLE_UPDATE_BY_EXAMPLE && aParam.isEmpty() ) { @@ -460,15 +489,15 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) } break; case SfxStyleFamily::Pseudo: - if(SfxItemState::SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, false, &pItem)) + if(const SfxStringItem* pExName = pArgs->GetItemIfSet(SID_STYLE_UPD_BY_EX_NAME, false)) { - aParam = static_cast<const SfxStringItem*>(pItem)->GetValue(); + aParam = pExName->GetValue(); } break; case SfxStyleFamily::Table: - if(SfxItemState::SET == pArgs->GetItemState(SID_STYLE_UPD_BY_EX_NAME, false, &pItem)) + if(const SfxStringItem* pExName = pArgs->GetItemIfSet(SID_STYLE_UPD_BY_EX_NAME, false)) { - aParam = static_cast<const SfxStringItem*>(pItem)->GetValue(); + aParam = pExName->GetValue(); } break; default: break; @@ -484,7 +513,8 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) switch(nSlot) { case SID_STYLE_EDIT: - Edit(aParam, OUString(), nFamily, nMask, false, OString(), pActShell); + case SID_STYLE_FONT: + Edit(rReq.GetFrameWeld(), aParam, {}, nFamily, nMask, false, (nSlot == SID_STYLE_FONT) ? "font" : OUString(), pActShell); break; case SID_STYLE_DELETE: Delete(aParam, nFamily); @@ -513,6 +543,10 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) OSL_FAIL("Invalid SlotId"); } + // Update formatting toolbar buttons status + if (GetWrtShell()->GetSelectionType() == SelectionType::PostIt) + GetView()->GetViewFrame().GetBindings().InvalidateAll(false); + if (bReturns) { if(rReq.IsAPI()) // Basic only gets TRUE or FALSE @@ -535,16 +569,16 @@ class ApplyStyle { public: ApplyStyle(SwDocShell &rDocSh, bool bNew, - rtl::Reference< SwDocStyleSheet > const & xTmp, + rtl::Reference< SwDocStyleSheet > xTmp, SfxStyleFamily nFamily, SfxAbstractApplyTabDialog *pDlg, - rtl::Reference< SfxStyleSheetBasePool > const & xBasePool, + rtl::Reference< SfxStyleSheetBasePool > xBasePool, bool bModified) : m_pDlg(pDlg) , m_rDocSh(rDocSh) , m_bNew(bNew) - , m_xTmp(xTmp) + , m_xTmp(std::move(xTmp)) , m_nFamily(nFamily) - , m_xBasePool(xBasePool) + , m_xBasePool(std::move(xBasePool)) , m_bModified(bModified) { } @@ -586,17 +620,19 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void) ::SfxToSwPageDescAttr( *pWrtShell, aSet ); // reset indent attributes at paragraph style, if a list style // will be applied and no indent attributes will be applied. - m_xTmp->SetItemSet( aSet, true ); + m_xTmp->SetItemSet( aSet, false, true ); } else { - if(SfxStyleFamily::Page == m_nFamily) + if(SfxStyleFamily::Page == m_nFamily || SfxStyleFamily::Frame == m_nFamily) { static const sal_uInt16 aInval[] = { SID_IMAGE_ORIENTATION, SID_ATTR_CHAR_FONT, - FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, 0}; - pView->GetViewFrame()->GetBindings().Invalidate(aInval); + FN_INSERT_CTRL, FN_INSERT_OBJ_CTRL, + FN_TABLE_INSERT_COL_BEFORE, + FN_TABLE_INSERT_COL_AFTER, 0}; + pView->GetViewFrame().GetBindings().Invalidate(aInval); } SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() ); if( SfxStyleFamily::Char == m_nFamily ) @@ -604,14 +640,49 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void) ::ConvertAttrGenToChar(aTmpSet, m_xTmp->GetItemSet()); } - m_xTmp->SetItemSet( aTmpSet ); + m_xTmp->SetItemSet( aTmpSet, false ); - if( SfxStyleFamily::Page == m_nFamily && SvtLanguageOptions().IsCTLFontEnabled() ) + if( SfxStyleFamily::Page == m_nFamily && SvtCTLOptions::IsCTLFontEnabled() ) { const SfxPoolItem *pItem = nullptr; - if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false ) , true, &pItem ) == SfxItemState::SET ) + if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhichIDFromSlotID( SID_ATTR_FRAMEDIRECTION, false ) , true, &pItem ) == SfxItemState::SET ) SwChartHelper::DoUpdateAllCharts( pDoc ); } + + if (m_nFamily == SfxStyleFamily::Page) + { + if (const SfxGrabBagItem* pGrabBagItem = aTmpSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) + { + bool bGutterAtTop{}; + auto it = pGrabBagItem->GetGrabBag().find("GutterAtTop"); + if (it != pGrabBagItem->GetGrabBag().end()) + { + it->second >>= bGutterAtTop; + } + bool bOldGutterAtTop + = pDoc->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP); + if (bOldGutterAtTop != bGutterAtTop) + { + pDoc->getIDocumentSettingAccess().set(DocumentSettingId::GUTTER_AT_TOP, + bGutterAtTop); + pWrtShell->InvalidateLayout(/*bSizeChanged=*/true); + } + } + } + + if (m_nFamily == SfxStyleFamily::Frame) + { + if (const SfxBoolItem* pBoolItem = aTmpSet.GetItemIfSet(FN_KEEP_ASPECT_RATIO)) + { + const SwViewOption* pVOpt = pWrtShell->GetViewOptions(); + SwViewOption aUsrPref(*pVOpt); + aUsrPref.SetKeepRatio(pBoolItem->GetValue()); + if (pBoolItem->GetValue() != pVOpt->IsKeepRatio()) + { + SW_MOD()->ApplyUsrPref(aUsrPref, &pWrtShell->GetView()); + } + } + } } if(m_bNew) @@ -622,7 +693,7 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void) SfxItemSet aTmpSet(*m_pDlg->GetOutputItemSet()); aTmpSet.ClearItem(XATTR_FILLSTYLE); - m_xTmp->SetItemSet(aTmpSet); + m_xTmp->SetItemSet(aTmpSet, false); } } @@ -708,12 +779,13 @@ void syncEndnoteOrientation(const uno::Reference< style::XStyleFamiliesSupplier } void SwDocShell::Edit( + weld::Window* pDialogParent, const OUString &rName, const OUString &rParent, const SfxStyleFamily nFamily, SfxStyleSearchBits nMask, const bool bNew, - const OString& sPage, + const OUString& sPage, SwWrtShell* pActShell, SfxRequest* pReq, sal_uInt16 nSlot) @@ -769,17 +841,6 @@ void SwDocShell::Edit( } pDStyle->GetCollection()->SetDerivedFrom( pColl ); pDStyle->PresetParent( rParent ); - - /*When a new paragraph style is created based on a "to outline style - assigned" paragraph style, the outline level attribute and the list - style attribute of the new paragraph style have to be set to 0 - respectively "".*/ - if (pColl && pColl->IsAssignedToListLevelOfOutlineStyle()) - { - SwNumRuleItem aItem; - pDStyle->GetCollection()->SetFormatAttr( aItem ); - pDStyle->GetCollection()->SetAttrOutlineLevel( 0 ); - } } else { @@ -877,6 +938,28 @@ void SwDocShell::Edit( rSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST)); rSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST)); rSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST)); + + std::optional<SfxGrabBagItem> oGrabBag; + if (SfxGrabBagItem const* pItem = rSet.GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) + { + oGrabBag.emplace(*pItem); + } + else + { + oGrabBag.emplace(SID_ATTR_CHAR_GRABBAG); + } + bool bGutterAtTop + = GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP); + oGrabBag->GetGrabBag()["GutterAtTop"] <<= bGutterAtTop; + rSet.Put(*oGrabBag); + } + + SwWrtShell* pCurrShell = pActShell ? pActShell : m_pWrtShell; + if (nFamily == SfxStyleFamily::Frame) + { + SfxItemSet& rSet = xTmp->GetItemSet(); + const SwViewOption* pVOpt = pCurrShell->GetViewOptions(); + rSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio())); } if (!bBasic) @@ -887,7 +970,6 @@ void SwDocShell::Edit( // In HTML mode, we do not always have a printer. In order to show // the correct page size in the Format - Page dialog, we have to // get one here. - SwWrtShell* pCurrShell = pActShell ? pActShell : m_pWrtShell; if( ( HTMLMODE_ON & nHtmlMode ) && !pCurrShell->getIDocumentDeviceAccess().getPrinter( false ) ) pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess().getPrinter( true ) ); @@ -896,7 +978,12 @@ void SwDocShell::Edit( FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode)); SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - VclPtr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(GetView()->GetFrameWeld(), + if (!pDialogParent) + { + SAL_WARN("sw.ui", "no parent for dialog supplied, assuming document frame is good enough"); + pDialogParent = GetView()->GetFrameWeld(); + } + VclPtr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(pDialogParent, *xTmp, nFamily, sPage, pCurrShell, bNew)); auto pApplyStyleHelper = std::make_shared<ApplyStyle>(*this, bNew, xTmp, nFamily, pDlg.get(), m_xBasePool, bModified); pDlg->SetApplyHdl(LINK(pApplyStyleHelper.get(), ApplyStyle, ApplyHdl)); @@ -1098,10 +1185,22 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa } case SfxStyleFamily::Para: { - // #i62675# - // clear also list attributes at affected text nodes, if paragraph - // style has the list style attribute set. - pSh->SetTextFormatColl( pStyle->GetCollection(), true ); + if (pSh->GetPostItMgr() && pSh->GetPostItMgr()->HasActiveSidebarWin()) + { + pSh->GetPostItMgr()->GetActiveSidebarWin()->GetOutlinerView()->SetStyleSheet(rName); + } + else + { + // When outline-folding is enabled, MakeAllOutlineContentTemporarilyVisible makes + // application of a paragraph style that has an outline-level greater than the previous + // outline node become folded content of the previous outline node if the previous + // outline node's content is folded. + MakeAllOutlineContentTemporarilyVisible a(GetDoc()); + // #i62675# + // clear also list attributes at affected text nodes, if paragraph + // style has the list style attribute set. + pSh->SetTextFormatColl( pStyle->GetCollection(), true ); + } break; } case SfxStyleFamily::Frame: @@ -1120,6 +1219,12 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa // reset indent attribute on applying list style // continue list of list style const SwNumRule* pNumRule = pStyle->GetNumRule(); + if (pNumRule->GetName() == SwResId(STR_POOLNUMRULE_NOLIST)) + { + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->Execute(FN_NUM_BULLET_OFF); + break; + } const OUString sListIdForStyle =pNumRule->GetDefaultListId(); pSh->SetCurNumRule( *pNumRule, false, sListIdForStyle, true ); break; @@ -1274,7 +1379,13 @@ void SwDocShell::UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWr break; case SfxStyleFamily::Table: { - + if (SwFEShell* pFEShell = GetFEShell()) + { + if(pFEShell->IsTableMode()) + { + pFEShell->TableCursorToCursor(); + } + } SwTableAutoFormat aFormat(rName); if (pCurrWrtShell->GetTableAutoFormat(aFormat)) { @@ -1287,6 +1398,8 @@ void SwDocShell::UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWr break; default: break; } + + m_xDoc->BroadcastStyleOperation(rName, nFamily, SfxHintId::StyleSheetModified); } // NewByExample @@ -1480,13 +1593,19 @@ void SwDocShell::MakeByExample( const OUString &rName, SfxStyleFamily nFamily, default: break; } + + m_xDoc->BroadcastStyleOperation(rName, nFamily, SfxHintId::StyleSheetCreated); } sfx::AccessibilityIssueCollection SwDocShell::runAccessibilityCheck() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY sw::AccessibilityCheck aCheck(m_xDoc.get()); aCheck.check(); return aCheck.getIssueCollection(); +#else + return sfx::AccessibilityIssueCollection(); +#endif } std::set<Color> SwDocShell::GetDocColors() @@ -1494,6 +1613,17 @@ std::set<Color> SwDocShell::GetDocColors() return m_xDoc->GetDocColors(); } +std::shared_ptr<model::ColorSet> SwDocShell::GetThemeColors() +{ + SdrModel* pModel = m_xDoc->getIDocumentDrawModelAccess().GetDrawModel(); + if (!pModel) + return {}; + auto const& pTheme = pModel->getTheme(); + if (!pTheme) + return {}; + return pTheme->getColorSet(); +} + void SwDocShell::LoadStyles( SfxObjectShell& rSource ) { LoadStyles_(rSource, false); @@ -1551,12 +1681,13 @@ void SwDocShell::LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocu } void SwDocShell::FormatPage( + weld::Window* pDialogParent, const OUString& rPage, - const OString& rPageId, + const OUString& rPageId, SwWrtShell& rActShell, SfxRequest* pRequest) { - Edit(rPage, OUString(), SfxStyleFamily::Page, SfxStyleSearchBits::Auto, false, rPageId, &rActShell, pRequest); + Edit(pDialogParent, rPage, OUString(), SfxStyleFamily::Page, SfxStyleSearchBits::Auto, false, rPageId, &rActShell, pRequest); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |