[Libreoffice-commits] core.git: sfx2/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 3 13:54:33 UTC 2020
sfx2/source/control/bindings.cxx | 20 +-
sfx2/source/control/thumbnailview.cxx | 206 +++++++++++++--------------
sfx2/source/doc/SfxRedactionHelper.cxx | 32 ++--
sfx2/source/doc/docfile.cxx | 34 ++--
sfx2/source/doc/docfilt.cxx | 28 +--
sfx2/source/sidebar/Deck.cxx | 46 +++---
sfx2/source/sidebar/SidebarDockingWindow.cxx | 22 +-
sfx2/source/view/viewfrm.cxx | 56 +++----
8 files changed, 222 insertions(+), 222 deletions(-)
New commits:
commit f659ec61a27a1a9fbdcb76a68e8de18a8a9fbbd7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sun Aug 2 20:09:29 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 3 15:53:55 2020 +0200
loplugin:flatten in sfx2
Change-Id: I2ff95614c82a6ed79e5ac593c85473a78ee41a62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99969
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index cdaf8362c578..94b9fea11e4b 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1628,18 +1628,18 @@ void SfxBindings::QueryControlState( sal_uInt16 nSlot, boost::property_tree::ptr
pImpl->pSubBindings->QueryControlState( nSlot, rState );
SfxStateCache* pCache = GetStateCache( nSlot );
- if ( pCache )
+ if ( !pCache )
+ return;
+
+ if ( pImpl->bMsgDirty )
{
- if ( pImpl->bMsgDirty )
- {
- UpdateSlotServer_Impl();
- pCache = GetStateCache( nSlot );
- }
+ UpdateSlotServer_Impl();
+ pCache = GetStateCache( nSlot );
+ }
- if (pCache && pCache->GetItemLink() )
- {
- pCache->GetState(rState);
- }
+ if (pCache && pCache->GetItemLink() )
+ {
+ pCache->GetState(rState);
}
}
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index b1ba09dfe23d..b37cb617b974 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -583,69 +583,69 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
Control::KeyInput( rKEvt );
}
- if ( pNext )
+ if ( !pNext )
+ return;
+
+ if (aKeyCode.IsShift() && bValidRange)
{
- if (aKeyCode.IsShift() && bValidRange)
- {
- std::pair<size_t,size_t> aRange;
- size_t nSelPos = mpStartSelRange - mFilteredItemList.begin();
+ std::pair<size_t,size_t> aRange;
+ size_t nSelPos = mpStartSelRange - mFilteredItemList.begin();
- if (nLastPos < nSelPos)
- {
- if (nNextPos > nLastPos)
- {
- if ( nNextPos > nSelPos)
- aRange = std::make_pair(nLastPos,nNextPos);
- else
- aRange = std::make_pair(nLastPos,nNextPos-1);
- }
- else
- aRange = std::make_pair(nNextPos,nLastPos-1);
- }
- else if (nLastPos == nSelPos)
+ if (nLastPos < nSelPos)
+ {
+ if (nNextPos > nLastPos)
{
- if (nNextPos > nLastPos)
- aRange = std::make_pair(nLastPos+1,nNextPos);
+ if ( nNextPos > nSelPos)
+ aRange = std::make_pair(nLastPos,nNextPos);
else
- aRange = std::make_pair(nNextPos,nLastPos-1);
+ aRange = std::make_pair(nLastPos,nNextPos-1);
}
+ else
+ aRange = std::make_pair(nNextPos,nLastPos-1);
+ }
+ else if (nLastPos == nSelPos)
+ {
+ if (nNextPos > nLastPos)
+ aRange = std::make_pair(nLastPos+1,nNextPos);
+ else
+ aRange = std::make_pair(nNextPos,nLastPos-1);
+ }
+ else
+ {
+ if (nNextPos > nLastPos)
+ aRange = std::make_pair(nLastPos+1,nNextPos);
else
{
- if (nNextPos > nLastPos)
- aRange = std::make_pair(nLastPos+1,nNextPos);
+ if ( nNextPos < nSelPos)
+ aRange = std::make_pair(nNextPos,nLastPos);
else
- {
- if ( nNextPos < nSelPos)
- aRange = std::make_pair(nNextPos,nLastPos);
- else
- aRange = std::make_pair(nNextPos+1,nLastPos);
- }
+ aRange = std::make_pair(nNextPos+1,nLastPos);
}
+ }
- for (size_t i = aRange.first; i <= aRange.second; ++i)
+ for (size_t i = aRange.first; i <= aRange.second; ++i)
+ {
+ if (i != nSelPos)
{
- if (i != nSelPos)
- {
- ThumbnailViewItem *pCurItem = mFilteredItemList[i];
+ ThumbnailViewItem *pCurItem = mFilteredItemList[i];
- pCurItem->setSelection(!pCurItem->isSelected());
+ pCurItem->setSelection(!pCurItem->isSelected());
- if (pCurItem->isVisible())
- DrawItem(pCurItem);
- }
+ if (pCurItem->isVisible())
+ DrawItem(pCurItem);
}
}
- else if (!aKeyCode.IsShift())
- {
- deselectItems();
- SelectItem(pNext->mnId);
-
- //Mark it as the selection range start position
- mpStartSelRange = mFilteredItemList.begin() + nNextPos;
- }
+ }
+ else if (!aKeyCode.IsShift())
+ {
+ deselectItems();
+ SelectItem(pNext->mnId);
- MakeItemVisible(pNext->mnId);
+ //Mark it as the selection range start position
+ mpStartSelRange = mFilteredItemList.begin() + nNextPos;
}
+
+ MakeItemVisible(pNext->mnId);
}
void ThumbnailView::MakeItemVisible( sal_uInt16 nItemId )
@@ -698,82 +698,82 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt )
return;
}
- if(rMEvt.GetClicks() == 1)
+ if(rMEvt.GetClicks() != 1)
+ return;
+
+ if (rMEvt.IsMod1())
{
- if (rMEvt.IsMod1())
- {
- //Keep selected item group state and just invert current desired one state
- pItem->setSelection(!pItem->isSelected());
+ //Keep selected item group state and just invert current desired one state
+ pItem->setSelection(!pItem->isSelected());
- //This one becomes the selection range start position if it changes its state to selected otherwise resets it
- mpStartSelRange = pItem->isSelected() ? mFilteredItemList.begin() + nPos : mFilteredItemList.end();
- }
- else if (rMEvt.IsShift() && mpStartSelRange != mFilteredItemList.end())
- {
- std::pair<size_t,size_t> aNewRange;
- aNewRange.first = mpStartSelRange - mFilteredItemList.begin();
- aNewRange.second = nPos;
+ //This one becomes the selection range start position if it changes its state to selected otherwise resets it
+ mpStartSelRange = pItem->isSelected() ? mFilteredItemList.begin() + nPos : mFilteredItemList.end();
+ }
+ else if (rMEvt.IsShift() && mpStartSelRange != mFilteredItemList.end())
+ {
+ std::pair<size_t,size_t> aNewRange;
+ aNewRange.first = mpStartSelRange - mFilteredItemList.begin();
+ aNewRange.second = nPos;
- if (aNewRange.first > aNewRange.second)
- std::swap(aNewRange.first,aNewRange.second);
+ if (aNewRange.first > aNewRange.second)
+ std::swap(aNewRange.first,aNewRange.second);
- //Deselect the ones outside of it
- for (size_t i = 0, n = mFilteredItemList.size(); i < n; ++i)
- {
- ThumbnailViewItem *pCurItem = mFilteredItemList[i];
+ //Deselect the ones outside of it
+ for (size_t i = 0, n = mFilteredItemList.size(); i < n; ++i)
+ {
+ ThumbnailViewItem *pCurItem = mFilteredItemList[i];
- if (pCurItem->isSelected() && (i < aNewRange.first || i > aNewRange.second))
- {
- pCurItem->setSelection(false);
+ if (pCurItem->isSelected() && (i < aNewRange.first || i > aNewRange.second))
+ {
+ pCurItem->setSelection(false);
- if (pCurItem->isVisible())
- DrawItem(pCurItem);
- }
+ if (pCurItem->isVisible())
+ DrawItem(pCurItem);
}
+ }
- size_t nSelPos = mpStartSelRange - mFilteredItemList.begin();
+ size_t nSelPos = mpStartSelRange - mFilteredItemList.begin();
- //Select the items between start range and the selected item
- if (nSelPos != nPos)
+ //Select the items between start range and the selected item
+ if (nSelPos != nPos)
+ {
+ int dir = nSelPos < nPos ? 1 : -1;
+ size_t nCurPos = nSelPos + dir;
+
+ while (nCurPos != nPos)
{
- int dir = nSelPos < nPos ? 1 : -1;
- size_t nCurPos = nSelPos + dir;
+ ThumbnailViewItem *pCurItem = mFilteredItemList[nCurPos];
- while (nCurPos != nPos)
+ if (!pCurItem->isSelected())
{
- ThumbnailViewItem *pCurItem = mFilteredItemList[nCurPos];
+ pCurItem->setSelection(true);
- if (!pCurItem->isSelected())
- {
- pCurItem->setSelection(true);
-
- if (pCurItem->isVisible())
- DrawItem(pCurItem);
- }
-
- nCurPos += dir;
+ if (pCurItem->isVisible())
+ DrawItem(pCurItem);
}
- }
-
- pItem->setSelection(true);
- }
- else
- {
- //If we got a group of selected items deselect the rest and only keep the desired one
- //mark items as not selected to not fire unnecessary change state events.
- pItem->setSelection(false);
- deselectItems();
- pItem->setSelection(true);
- //Mark as initial selection range position and reset end one
- mpStartSelRange = mFilteredItemList.begin() + nPos;
+ nCurPos += dir;
+ }
}
- if (!pItem->isHighlighted())
- DrawItem(pItem);
+ pItem->setSelection(true);
+ }
+ else
+ {
+ //If we got a group of selected items deselect the rest and only keep the desired one
+ //mark items as not selected to not fire unnecessary change state events.
+ pItem->setSelection(false);
+ deselectItems();
+ pItem->setSelection(true);
- //fire accessible event??
+ //Mark as initial selection range position and reset end one
+ mpStartSelRange = mFilteredItemList.begin() + nPos;
}
+
+ if (!pItem->isHighlighted())
+ DrawItem(pItem);
+
+ //fire accessible event??
}
void ThumbnailView::Command( const CommandEvent& rCEvt )
diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx
index 408c733c77e9..b41f197d09d6 100644
--- a/sfx2/source/doc/SfxRedactionHelper.cxx
+++ b/sfx2/source/doc/SfxRedactionHelper.cxx
@@ -278,23 +278,23 @@ void SfxRedactionHelper::showRedactionToolbar(const SfxViewFrame* pViewFrame)
Reference<css::beans::XPropertySet> xPropSet(xFrame, UNO_QUERY);
Reference<css::frame::XLayoutManager> xLayoutManager;
- if (xPropSet.is())
+ if (!xPropSet.is())
+ return;
+
+ try
{
- try
- {
- Any aValue = xPropSet->getPropertyValue("LayoutManager");
- aValue >>= xLayoutManager;
- xLayoutManager->createElement("private:resource/toolbar/redactionbar");
- xLayoutManager->showElement("private:resource/toolbar/redactionbar");
- }
- catch (const css::uno::RuntimeException&)
- {
- throw;
- }
- catch (css::uno::Exception&)
- {
- SAL_WARN("sfx.doc", "Exception while trying to show the Redaction Toolbar!");
- }
+ Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ xLayoutManager->createElement("private:resource/toolbar/redactionbar");
+ xLayoutManager->showElement("private:resource/toolbar/redactionbar");
+ }
+ catch (const css::uno::RuntimeException&)
+ {
+ throw;
+ }
+ catch (css::uno::Exception&)
+ {
+ SAL_WARN("sfx.doc", "Exception while trying to show the Redaction Toolbar!");
}
}
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 908802be2f33..4114273f2cc6 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3017,30 +3017,30 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream )
catch( const uno::Exception& )
{}
- if(pImpl->m_bMSOLockFileCreated)
- {
- ::svt::MSODocumentLockFile aMSOLockFile( pImpl->m_aLogicName );
+ if(!pImpl->m_bMSOLockFileCreated)
+ return;
+
+ ::svt::MSODocumentLockFile aMSOLockFile( pImpl->m_aLogicName );
+ try
+ {
+ pImpl->m_bLocked = false;
+ // TODO/LATER: A warning could be shown in case the file is not the own one
+ aMSOLockFile.RemoveFile();
+ }
+ catch( const io::WrongFormatException& )
+ {
try
{
- pImpl->m_bLocked = false;
- // TODO/LATER: A warning could be shown in case the file is not the own one
- aMSOLockFile.RemoveFile();
- }
- catch( const io::WrongFormatException& )
- {
- try
- {
- // erase the empty or corrupt file
- aMSOLockFile.RemoveFileDirectly();
- }
- catch( const uno::Exception& )
- {}
+ // erase the empty or corrupt file
+ aMSOLockFile.RemoveFileDirectly();
}
catch( const uno::Exception& )
{}
- pImpl->m_bMSOLockFileCreated = false;
}
+ catch( const uno::Exception& )
+ {}
+ pImpl->m_bMSOLockFileCreated = false;
#endif
}
diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx
index 2e71007b3129..18f38d422ffe 100644
--- a/sfx2/source/doc/docfilt.cxx
+++ b/sfx2/source/doc/docfilt.cxx
@@ -65,22 +65,22 @@ SfxFilter::SfxFilter( const OUString &rName,
{
const OUString aExts = GetWildcard().getGlob();
sal_Int32 nLen{ aExts.getLength() };
- if (nLen>0)
+ if (nLen<=0)
+ return;
+
+ // truncate to first empty extension
+ if (aExts[0]==';')
{
- // truncate to first empty extension
- if (aExts[0]==';')
- {
- aWildCard.setGlob("");
- return;
- }
- const sal_Int32 nIdx{ aExts.indexOf(";;") };
- if (nIdx>0)
- nLen = nIdx;
- else if (aExts[nLen-1]==';')
- --nLen;
- if (nLen<aExts.getLength())
- aWildCard.setGlob(aExts.copy(0, nLen));
+ aWildCard.setGlob("");
+ return;
}
+ const sal_Int32 nIdx{ aExts.indexOf(";;") };
+ if (nIdx>0)
+ nLen = nIdx;
+ else if (aExts[nLen-1]==';')
+ --nLen;
+ if (nLen<aExts.getLength())
+ aWildCard.setGlob(aExts.copy(0, nLen));
}
SfxFilter::~SfxFilter()
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 3088eb245497..1096a0af5eaa 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -291,32 +291,32 @@ void Deck::RequestLayout()
{
RequestLayoutInternal();
- if (comphelper::LibreOfficeKit::isActive())
- {
- bool bChangeNeeded = false;
- Size aParentSize = GetParent()->GetSizePixel();
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
- if (mnMinimalHeight > 0 && (mnMinimalHeight != aParentSize.Height() || GetSizePixel().Height() != mnMinimalHeight))
- {
- aParentSize.setHeight(mnMinimalHeight);
- bChangeNeeded = true;
- }
- const SfxViewShell* pViewShell = SfxViewShell::Current();
- if (mnMinimalWidth > 0 && (mnMinimalWidth != aParentSize.Width() || GetSizePixel().Width() != mnMinimalWidth)
- && pViewShell && pViewShell->isLOKMobilePhone())
- {
- aParentSize.setWidth(mnMinimalWidth);
- bChangeNeeded = true;
- }
+ bool bChangeNeeded = false;
+ Size aParentSize = GetParent()->GetSizePixel();
- if (bChangeNeeded)
- {
- GetParent()->SetSizePixel(aParentSize);
- setPosSizePixel(0, 0, aParentSize.Width(), aParentSize.Height());
- }
- else if (aParentSize != GetSizePixel()) //Sync parent & child sizes
- setPosSizePixel(0, 0, aParentSize.Width(), aParentSize.Height());
+ if (mnMinimalHeight > 0 && (mnMinimalHeight != aParentSize.Height() || GetSizePixel().Height() != mnMinimalHeight))
+ {
+ aParentSize.setHeight(mnMinimalHeight);
+ bChangeNeeded = true;
+ }
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (mnMinimalWidth > 0 && (mnMinimalWidth != aParentSize.Width() || GetSizePixel().Width() != mnMinimalWidth)
+ && pViewShell && pViewShell->isLOKMobilePhone())
+ {
+ aParentSize.setWidth(mnMinimalWidth);
+ bChangeNeeded = true;
+ }
+
+ if (bChangeNeeded)
+ {
+ GetParent()->SetSizePixel(aParentSize);
+ setPosSizePixel(0, 0, aParentSize.Width(), aParentSize.Height());
}
+ else if (aParentSize != GetSizePixel()) //Sync parent & child sizes
+ setPosSizePixel(0, 0, aParentSize.Width(), aParentSize.Height());
}
vcl::Window* Deck::GetPanelParentWindow()
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 8cc420001210..c3bbe327fab7 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -194,20 +194,20 @@ void SidebarDockingWindow::SyncUpdate()
void SidebarDockingWindow::NotifyResize()
{
- if (comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current())
- {
- const vcl::ILibreOfficeKitNotifier* pCurrentView = SfxViewShell::Current();
- if (GetLOKNotifier() != pCurrentView)
- {
- // ViewShell not yet set, or has changed. Reset it.
- // Note GetLOKWindowId will return a new value after resetting, so we must notify clients.
- LOKClose();
+ if (!(comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current()))
+ return;
- SetLOKNotifier(pCurrentView);
- }
+ const vcl::ILibreOfficeKitNotifier* pCurrentView = SfxViewShell::Current();
+ if (GetLOKNotifier() != pCurrentView)
+ {
+ // ViewShell not yet set, or has changed. Reset it.
+ // Note GetLOKWindowId will return a new value after resetting, so we must notify clients.
+ LOKClose();
- mpIdleNotify->Start();
+ SetLOKNotifier(pCurrentView);
}
+
+ mpIdleNotify->Start();
}
SfxChildAlignment SidebarDockingWindow::CheckAlignment (
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 027fb8285c08..0d2dcb2e5afa 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1235,39 +1235,39 @@ void SfxViewFrame::AppendReadOnlyInfobar()
auto pInfoBar = AppendInfoBar("readonly", "",
SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT),
InfobarType::INFO);
- if (pInfoBar)
+ if (!pInfoBar)
+ return;
+
+ if (bSignPDF)
{
- if (bSignPDF)
+ // SID_SIGNPDF opened a read-write PDF
+ // read-only for signing purposes.
+ VclPtrInstance<PushButton> xSignButton(&GetWindow());
+ if (bSignWithCert)
{
- // SID_SIGNPDF opened a read-write PDF
- // read-only for signing purposes.
- VclPtrInstance<PushButton> xSignButton(&GetWindow());
- if (bSignWithCert)
- {
- xSignButton->SetText(SfxResId(STR_READONLY_FINISH_SIGN));
- }
- else
- {
- xSignButton->SetText(SfxResId(STR_READONLY_SIGN));
- }
-
- xSignButton->SetSizePixel(xSignButton->GetOptimalSize());
- xSignButton->SetClickHdl(LINK(this, SfxViewFrame, SignDocumentHandler));
- pInfoBar->addButton(xSignButton);
+ xSignButton->SetText(SfxResId(STR_READONLY_FINISH_SIGN));
}
-
- bool showEditDocumentButton = true;
- if (m_xObjSh->isEditDocLocked())
- showEditDocumentButton = false;
-
- if (showEditDocumentButton)
+ else
{
- VclPtrInstance<PushButton> xBtn(&GetWindow());
- xBtn->SetText(SfxResId(STR_READONLY_EDIT));
- xBtn->SetSizePixel(xBtn->GetOptimalSize());
- xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
- pInfoBar->addButton(xBtn);
+ xSignButton->SetText(SfxResId(STR_READONLY_SIGN));
}
+
+ xSignButton->SetSizePixel(xSignButton->GetOptimalSize());
+ xSignButton->SetClickHdl(LINK(this, SfxViewFrame, SignDocumentHandler));
+ pInfoBar->addButton(xSignButton);
+ }
+
+ bool showEditDocumentButton = true;
+ if (m_xObjSh->isEditDocLocked())
+ showEditDocumentButton = false;
+
+ if (showEditDocumentButton)
+ {
+ VclPtrInstance<PushButton> xBtn(&GetWindow());
+ xBtn->SetText(SfxResId(STR_READONLY_EDIT));
+ xBtn->SetSizePixel(xBtn->GetOptimalSize());
+ xBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler));
+ pInfoBar->addButton(xBtn);
}
}
More information about the Libreoffice-commits
mailing list